package ai.leinao.notify.dingtalk.domain;

import ai.leinao.notify.core.utils.TemplateUtils;
import cn.hutool.json.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

import java.util.Map;

/**
 * 钉钉机器人MarkDown消息
 *
 * @author zhong.wang
 * @date 2025/7/11
 */
@AllArgsConstructor
@Setter
@Getter
public class DingTalkRobotMarkDown {
    /**
     * 标题
     */
    private String title;

    /**
     * 内容
     */
    private String text;

    public DingTalkRobotMarkDown render(Map<String, Object> context) {
        return new DingTalkRobotMarkDown(TemplateUtils.simpleRender(title, context), TemplateUtils.simpleRender(text, context));
    }

    public JSONObject toJson() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("title", title);
        jsonObject.put("text", text);
        return jsonObject;
    }
}
